﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using Com.CMS263.BLL;
using Com.CMS263.PO;
using Com.CMS263.Util;

namespace Com.CMS263.Web.manage.OrderManage
{
    public partial class order_list : System.Web.UI.Page
    {
        //searchkey start
        public int state = 0;
        public int styleid = 0;
        //searchkey end
        public IList<UserOrder> prodlist = new List<UserOrder>();
        public ArtBaseBLL abbll = new ArtBaseBLL();
        public int page = 0;
        public int pagecount = 0;
        public int pagesize = 20;
        UserOrderBLL uobll = new UserOrderBLL();
        public CustomerList cust = new CustomerList();
        public CustomerListBLL custbll = new CustomerListBLL();

        public IList<Province> provlist = new List<Province>();
        ProvinceBLL provbll = new ProvinceBLL();
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                state = Convert.ToInt32(Request["state"]);
                styleid = Convert.ToInt32(Request["styleid"]);

                page = Convert.ToInt32(Request["page"]);
                if (page == 0)
                {
                    page = 1;
                }
                prodlist = uobll.GetListByStyleAndState(styleid, state, page, pagesize);
                provlist = provbll.GetAllProvince();
            }
        }
        public string GetTypeName(object obj)
        {
            int type = Convert.ToInt32(obj);
            switch (type)
            {
                case 1:
                    return "婚纱";
                case 2:
                    return "喜酒";
                case 3:
                    return "喜帖";
                case 4:
                    return "珠宝";
                case 5:
                    return "礼品";
                default:
                    return "婚纱";
            }
        }

        protected void btnSearch_Click(object sender, EventArgs e)
        {
            state = Convert.ToInt32(Request["txtSearchState"]);
            styleid = Convert.ToInt32(Request["txtSearchStyle"]);

            Response.Redirect("order_list.aspx?state=" + state + "&styleid=" + styleid);
        }
        public string GetPager()
        {
            pagecount = uobll.GetListByStyleAndState(styleid, state);
            return EnPager.GetPager(pagecount, pagesize, page, "&state=" + state + "&styleid=" + styleid);
        }

        protected void btnBatch_Click(object sender, EventArgs e)
        {
            int editstate = Convert.ToInt32(Request["txtBatch"]);
            string ids = Request["chk"];
            page = Convert.ToInt32(Request["page"]);
            if (page == 0)
            {
                page = 1;
            }
            if (uobll.EditOrderState(ids, editstate))
            {
                StringUtil.Alert("修改成功", "order_list.aspx?state=" + state + "&styleid=" + styleid + "&page=" + page);
            }
            else
            {
                StringUtil.Alert("修改失败", "order_list.aspx?state=" + state + "&styleid=" + styleid + "&page=" + page);

            }

        }
    }
}
